package airplane.interfaz;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

/**
 * Passenger information buttons
 */
public class PassengerDataButtonPane extends JPanel implements ActionListener
{

    //-----------------------------------------------------------------
    // Constants
    //-----------------------------------------------------------------

    /**
     * Opción Aceptar
     */
    public final static String ACCEPT = "ACCEPT";

    //-----------------------------------------------------------------
    // GUI Fields
    //-----------------------------------------------------------------

    /**
     * Main window
     */
    private PassengerDataWindow window;

    /**
     * Accept Button
     */
    private JButton buttonAccept;

    //-----------------------------------------------------------------
    // Constructors
    //-----------------------------------------------------------------

    /**
     * It builds the button pane for the passenger information window
     * @param theWindow - Window the pane is part of
     */
    public PassengerDataButtonPane( PassengerDataWindow theWindow )
    {
        setLayout( new GridLayout( 1, 2, 10, 1 ) );
        window = theWindow;

        //Accept
        buttonAccept = new JButton( );
        buttonAccept.setText( "Accept" );
        buttonAccept.setActionCommand( ACCEPT );
        buttonAccept.addActionListener( this );
        add( buttonAccept );
    }

    //-----------------------------------------------------------------
    // Methods
    //-----------------------------------------------------------------
    /**
     * Response actions to the graphical events
     * @param event - event generated by a graphical element
     */
    public void actionPerformed( ActionEvent event )
    {
        String command = event.getActionCommand( );

        if( command.equals( ACCEPT ) )
        {
            window.accept( );
        }
    }
}